package com.itheima.d16_innerClassanonymous;

/**
 * 学校要求老师、学生、运动员一起游泳
 */

public class Test2 {
    //掌握匿名内部类书写
    public static void main(String[] args) {
        Swim teacher = new Teacher();
        go(teacher);

        Swim student = new Swim() {
            @Override
            public void swimming() {
                System.out.println("学生游泳");
            }
        };
        go(student);
        go(new Swim() {
            @Override
            public void swimming() {
                System.out.println("运动员游泳");
            }
        });
    }
    public static void  go(Swim swim){
        swim.swimming();
    }
}
interface  Swim{
    void swimming();
}
class Teacher implements Swim{

    @Override
    public void swimming() {
        System.out.println("教师游泳");
    }
}